<template>
  <div class="app-container">
    <el-tabs v-model="tabActiveName" type="card">
      <el-tab-pane label="期末结账" name="first">
        <p>{{ year }}年</p>
        <div class="month-card-list">
          <div
            v-for="(item, index) in firstList"
            :class="{'month-card': true, green: true}"
            :key="index"
            @click="cardClickHandler(item)"
          >{{ item.month }}月</div>
        </div>
        <el-button type="primary" size="small" @click="openD">出纳</el-button>
      </el-tab-pane>
      <el-tab-pane label="反结账" name="second">
        <p>{{ year }}年</p>
        <div class="month-card-list">
          <div
            v-for="(item, index) in firstList"
            :class="{'month-card': true, blue: true}"
            :key="index"
            @click="cardClickHandler(item)"
          >{{ item.month }}月</div>
        </div>
      </el-tab-pane>
    </el-tabs>
    <el-dialog :visible.sync="dialogSubVisible" :title="dialogSubTitle">
      <cashier v-if="dialogSubType === 'cashier'"/>
      <subject v-if="dialogSubType === 'subject'"/>
      <balance v-if="dialogSubType === 'balance'"/>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogSubVisible = false">取消</el-button>
        <el-button type="primary" @click="dialogSubHandler">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Cashier from './sub/cashier'
import Subject from './sub/subject'
import Balance from './sub/balance'
export default {
  name: 'SettleAccounts',
  components: {
    Cashier,
    Subject,
    Balance
  },
  data() {
    const firstList = []
    const secondList = []
    for (let i = 0; i < 12; i++) {
      firstList.push({
        month: i + 1
      })
      secondList.push({
        month: i + 1
      })
    }
    return {
      tabActiveName: 'first',
      firstList,
      secondList,
      year: 2019,
      dialogSubVisible: false,
      dialogSubTitle: '',
      dialogSubType: ''
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    cardClickHandler() {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        showClose: false
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    openD() {
      this.dialogSubVisible = true
      this.dialogSubTitle = 'aaaaa'
      this.dialogSubType = 'cashier'
    },
    dialogSubHandler() {
      this.dialogSubVisible = false
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .month-card-list {
    .month-card {
      display: inline-block;
      width: 80px;
      height: 80px;
      line-height: 80px;
      text-align: center;
      border-radius: 4px;
      color: rgb(120, 120, 120);
      background-color: rgb(230, 230, 230);
      margin-right: 10px;
      cursor: pointer;
      &:last-child{
        margin-right: 0;
      }
      &.blue {
        line-height: 78px;
        border: 1px solid rgb(26, 132, 232);
        color: rgb(26, 132, 232);
        background-color: rgb(228, 238, 248);
      }
      &.green {
        line-height: 78px;
        border: 1px solid rgb(33, 167, 105);
        color: rgb(33, 167, 105);
        background-color: rgb(225, 236, 232);
      }
    }
  }
</style>
